Fix ContextualLogger bypassing Serilog destructuring policies (v11)#873
Merged
mishioo merged 2 commits intov11.0-previewfrom Apr 16, 2026
Merged
Fix ContextualLogger bypassing Serilog destructuring policies (v11)#873mishioo merged 2 commits intov11.0-previewfrom
mishioo merged 2 commits intov11.0-previewfrom
Conversation
Summary
Skipped
🎉 No failed tests in this run. Github Test Reporter by CTRF 💚 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v11.0-preview #873 +/- ##
=================================================
- Coverage 85.57% 85.41% -0.17%
=================================================
Files 246 246
Lines 5206 5210 +4
Branches 388 379 -9
=================================================
- Hits 4455 4450 -5
- Misses 668 676 +8
- Partials 83 84 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
marcin-dardzinski
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
same as #872
Summary
ContextualLogger<T>only implementedWrite(LogEvent). On Serilog 4.x,Information,Warning, and similar APIs are default interface methods onSerilog.ILoggerthat bind templates via an internal unconfigured logger, so registeredIDestructuringPolicyinstances (includingBaseSanitizer<T>) were never applied. Message binding must use the same configuredSerilog.ILoggerinstance that owns the pipeline (including sanitizers).This change implements
BindMessageTemplateonContextualLogger<T>and forwards to the inner logger.NullLogger<T>implementsBindMessageTemplateby returningfalseso binding does not use the default static implementation.Test plan
ContextualLoggerDestructuringTests: configures a logger withDestructure.With<RightSanitizer>(), logs{@Payload}throughLeanCode.Logging.ILogger<T>(ContextualLogger), and asserts the captured property reflects sanitization (placeholder present, raw secret string absent).Notes
falsefromBindMessageTemplateavoids constructing log events from the default binding path; behavior remains a no-op for logging.Made with Cursor.